package com.xbongbong.admin.model.impl;

import com.xbongbong.admin.domain.dao.MirrorChartDao;
import com.xbongbong.admin.domain.entity.MirrorChartEntity;
import com.xbongbong.admin.model.MirrorChartModel;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @auther: xingxing.xiao
 * @date: 2020/3/6 006 15:46
 */
@Service("mirrorChartModel")
public class MirrorChartModelImpl implements MirrorChartModel {

    @Resource
    private MirrorChartDao mirrorChartDao;

    @Override
    public Integer insert(MirrorChartEntity entity) throws XbbException {
        long now = DateUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return mirrorChartDao.insert(entity);
    }

    @Override
    public Integer update(MirrorChartEntity entity) throws XbbException {
        long now = DateUtil.getInt();
        entity.setUpdateTime(now);
        return mirrorChartDao.update(entity);
    }

    @Override
    public List<MirrorChartEntity> findEntitys(Map<String, Object> param) {
        return mirrorChartDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return mirrorChartDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public Integer deleteByKey(Long key, Long mirrorId) {
        return mirrorChartDao.deleteByKey(key, mirrorId);
    }

    @Override
    public MirrorChartEntity getByKey(Long key, Long mirrorId) {
        return mirrorChartDao.getByKey(key, mirrorId);
    }

    @Override
    public List<MirrorChartEntity> insertBatch(List<MirrorChartEntity> list) {
        mirrorChartDao.insertBatch(list);
        return list;
    }
}
